Zdroj: https://cs.education-wiki.com/7689832-ftp-commands


Úvod do FTP příkazu
FTP znamená File Transfer Protocol. Odpovědností FTP je převést soubor z jednoho umístění do druhého. Pro transformaci souboru FTP používá služby TCP. Používá dvě připojení TCP, tj. Řídicí připojení a datové připojení. Jak řídicí připojení, tak datové připojení používají známý port 21 respektive známý port 20. V tomto článku probereme různé FTP příkazy.

Zpracování příkazů v FTP

Pro komunikaci klient posílá příkazy serveru a na oplátku server odešle odpověď klientovi. Příkazy odesílané ze strany klienta jsou ve formě znakové sady ASCII.

FTP příkazy
Příkazy FTP lze rozdělit do následujících šesti skupin.

1. Přístup k příkazům
2. Příkazy pro správu souborů
3. Příkazy formátování dat
4. Příkazy definující port
5. Příkazy pro přenos souborů
6. Různé příkazy

Pojďme diskutovat tyto příkazy jeden po druhém


1.Příkazy vstupu:
Uživatel může tyto příkazy použít pro přístup ke vzdálenému systému.

Níže je uveden seznam přístupových příkazů

USER : Tento příkaz se používá k poskytnutí informací o uživateli. Trvá jeden argument, tj. ID uživatele.
PASS : Tento příkaz se používá k nastavení hesla uživatele nebo pomocí tohoto uživatele se může přihlásit do systému. 	Vyžaduje jeden argument, tj. Uživatelské heslo.
ACCT : Poskytuje informace o uživatelském účtu. Vyžaduje jeden argument, tj. Název účtu
QUIT : K odhlášení ze systému se používá tento příkaz.
ABOR : Přeruší předchozí příkaz.
REIN : Používá se k inicializaci systému.



2. Příkazy pro správu souborů:
Uživatelé mohou pomocí těchto příkazů přistupovat k systému souborů přítomnému ve vzdáleném systému. Umožňuje uživateli vytvořit nový adresář, mazat soubory, procházet adresáře atd

Níže je uveden seznam příkazů pro správu souborů

CWD  : Tento příkaz se používá k přepínání z jednoho adresáře do druhého. Vezme jeden argument, tj. Název adresáře.
CDUP : Používá se k přepnutí do nadřazeného adresáře.
DELE : Používá se k odstranění souboru z adresáře. Vezme jeden argument, tj. Název souboru.
LIST : Poskytne seznam všech souborů přítomných v zadaném adresáři. Vezme jeden argument, tj. Název adresáře.
NLIST: Poskytne seznam souborů bez jejich atributů přítomných v zadaném adresáři. Vezme jeden argument, tj. Název adresáře.
MKD :  Tento příkaz se používá k vytvoření nového adresáře. Vezme jeden argument, tj. Název adresáře
RMD :  Tento příkaz se používá k odstranění adresáře. Vezme jeden argument, tj. Název adresáře.
PWD :  Zobrazí název aktuálního adresáře.
RNTO : Používá se k přejmenování souboru. Vyžaduje jeden argument, tj. Nový název souboru
SMNT : Používá se pro připojení souborového systému. To trvá jeden argument, tj. Název systému souborů.
RNFR : Používá se k identifikaci souboru, který je třeba přejmenovat. Vyžaduje jeden argument, tj. Starý název souboru.



3. Příkazy pro formátování dat:
pro definování datových atributů byly tyto příkazy použity. Definuje atributy dat, jako je typ souboru, struktura dat a režimy přenosu.

TYPE : Definuje typ souboru. Definování typu souboru trvá pět argumentů. A pro ASCII, E pro EBCDIC, I pro obraz, N pro netisk a T pro telnet.
STRU : Definuje organizaci dat. Vyžaduje to tři argumenty. F pro soubor, R pro záznam a P pro stránku.
MODE : Tento příkaz se používá k definování režimu přenosu souboru. Vyžaduje to tři argumenty. S pro proud, B pro blok a C pro komprimovaný.



4. Příkazy definující port:
Používá se pro definování čísla portu pro připojení na straně klienta. Číslo portu lze přiřadit jedním z následujících způsobů

Klient si může pomocí příkazu PORT vybrat číslo dočasného portu a poté jej odeslat na server pomocí pasivního otevření. Po obdržení čísla efemérního portu vytvoří sever aktivní otevření.
Klient použije příkaz PASV a řekne serveru, aby vybral libovolné číslo portu. Server provede pasivní otevření tohoto čísla portu a odešle toto číslo portu klientovi. Po obdržení čísla portu ze serveru vydá klient aktivní číslo otevřené pro dané číslo portu.
Níže je uveden seznam příkazů definujících port

PORT : Tento příkaz umožňuje klientovi zvolit číslo portu. Vyžaduje jeden argument, tj. Šestimístný identifikátor.
PASV : Tento příkaz umožní serveru zvolit číslo portu.




5. Příkazy pro přenos souborů:
Pro přenos souborů se tyto příkazy používají. Tyto příkazy mají jeden argument, tj. Název souboru.

Níže je uveden seznam příkazů pro přenos souborů

RETR : Tento příkaz používá klient k načtení souborů ze serveru.
STOR : Tento příkaz používá klient k ukládání souborů na server.
APPE : Je podobný příkazu STOR, ale pokud existuje soubor, musí k němu být připojena data.
STOU : Je také podobný příkazu STOR, ale každý název souboru by měl být v adresáři jedinečný.
ALLO : Tento příkaz slouží k přidělení úložného prostoru pro soubory na serveru.
STAT : Tento příkaz zobrazí stav zadaných souborů.
REST : Tento příkaz umístí značku souboru na určené datové body.




6. Různé příkazy:
Tyto příkazy se používají pro doručování informací uživateli FTP na straně klienta.

Níže je uveden seznam různých příkazů.

NÁPOVĚDA : Tento příkaz zobrazí informace o serveru.
NOOP : Tento příkaz se používá ke kontrole, zda je server naživu nebo ne.
SITE : Tento příkaz specifikuje konkrétní příkazy. Trvá jeden argument, tj. Příkazy.
SYST : Tento příkaz zobrazí informace o operačním systému používaném serverem.




Odpovědi FTP serveru:

List of FTP server return codes
From Wikipedia, the free encyclopedia

FTP server return codes always have three digits, and each digit has a special meaning.[1] The first digit denotes whether the response is good, bad or incomplete:

Range	Purpose
1xx	Positive Preliminary reply
	The requested action is being initiated; expect another reply before proceeding with a new command. (The user-	process sending another command before the completion reply would be in violation of protocol; but server-FTP 	processes should queue any commands that arrive while a preceding command is in progress.) This type of reply can be 	used to indicate that the command was accepted and the user-process may now pay attention to the data connections, 	for implementations where simultaneous monitoring is difficult. The server-FTP process may send at most, one 1xx 	reply per command.

2xx	Positive Completion reply
	The requested action has been successfully completed. A new request may be initiated.

3xx	Positive Intermediate reply
	The command has been accepted, but the requested action is being held in abeyance, pending receipt of further 	information. The user should send another command specifying this information. This reply is used in command 	sequence groups.

4xx	Transient Negative Completion reply
	The command was not accepted and the requested action did not take place, but the error condition is temporary and 	the action may be requested again. The user should return to the beginning of the command sequence, if any. It is 	difficult to assign a meaning to "transient", particularly when two distinct sites (Server- and User-processes) have 	to agree on the interpretation. Each reply in the 4xx category might have a slightly different time value, but the 	intent is that the user-process is encouraged to try again. A rule of thumb in determining if a reply fits into the 	4xx or the 5xx (Permanent Negative) category is that replies are 4xx if the commands can be repeated without any 	change in command form or in properties of the User or Server (e.g., the command is spelled the same with the same 	arguments used; the user does not change his file access or user name; the server does not put up a new 	implementation.)

5xx	Permanent Negative Completion reply
	The command was not accepted and the requested action did not take place. The User-process is discouraged from 	repeating the exact request (in the same sequence). Even some "permanent" error conditions can be corrected, so the 	human user may want to direct his User-process to reinitiate the command sequence by direct action at some point in 	the future (e.g., after the spelling has been changed, or the user has altered his directory status.)

6xx	Protected reply
	The RFC 2228 introduced the concept of protected replies to increase security over the FTP communications. The 6xx 	replies are Base64 encoded protected messages that serves as responses to secure commands. When properly decoded, 	these replies fall into the above categories.

	The second digit is a grouping digit and encodes the following information:

Range	Purpose
x0x	Syntax
	These replies refer to syntax errors, syntactically correct commands that don't fit any functional category, 	unimplemented or superfluous commands.

x1x	Information
	These are replies to requests for information, such as status or help.

x2x	Connections
	Replies referring to the control and data connections.

x3x	Authentication and accounting
	Replies for the login process and accounting procedures.

x4x	Unspecified as of RFC 959.
x5x	File system
	These replies indicate the status of the Server file system vis-a-vis the requested transfer or other file system 	action.

Below is a list of all known return codes that may be issued by an FTP server.

Code	Explanation
100 Series	The requested action is being initiated, expect another reply before proceeding with a new command.
110	Restart marker replay . In this case, the text is exact and not left to the particular implementation; it must read: 	MARK yyyy = mmmm where yyyy is User-process data stream marker, and mmmm server's equivalent marker (note the spaces 	between markers and "=").
120	Service ready in nnn minutes.
125	Data connection already open; transfer starting.
150	File status okay; about to open data connection.

200 Series	The requested action has been successfully completed.
202	Command not implemented, superfluous at this site.
211	System status, or system help reply.
212	Directory status.
213	File status.
214	Help message. Explains how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user.
215	NAME system type. Where NAME is an official system name from the registry kept by IANA.
220	Service ready for new user.
221	Service closing control connection.
225	Data connection open; no transfer in progress.
226	Closing data connection. Requested file action successful (for example, file transfer or file abort).
227	Entering Passive Mode (h1,h2,h3,h4,p1,p2).
228	Entering Long Passive Mode (long address, port).
229	Entering Extended Passive Mode (|||port|).
230	User logged in, proceed. Logged out if appropriate.
231	User logged out; service terminated.
232	Logout command noted, will complete when transfer done.
234	Specifies that the server accepts the authentication mechanism specified by the client, and the exchange of security data is complete. A higher level nonstandard code created by Microsoft.
250	Requested file action okay, completed.
257	"PATHNAME" created.

300 Series	The command has been accepted, but the requested action is on hold, pending receipt of further information.
331	User name okay, need password.
332	Need account for login.
350	Requested file action pending further information

400 Series	The command was not accepted and the requested action did not take place, but the error condition is temporary and the action may be requested again.
421	Service not available, closing control connection. This may be a reply to any command if the service knows it must shut down.
425	Can't open data connection.
426	Connection closed; transfer aborted.
430	Invalid username or password
434	Requested host unavailable.
450	Requested file action not taken.
451	Requested action aborted. Local error in processing.
452	Requested action not taken. Insufficient storage space in system. File unavailable (e.g., file busy).

500 Series	Syntax error, command unrecognized and the requested action did not take place. This may include errors such as command line too long.
501	Syntax error in parameters or arguments.
502	Command not implemented.
503	Bad sequence of commands.
504	Command not implemented for that parameter.
530	Not logged in.
532	Need account for storing files.
534	Could Not Connect to Server - Policy Requires SSL
550	Requested action not taken. File unavailable (e.g., file not found, no access).
551	Requested action aborted. Page type unknown.
552	Requested file action aborted. Exceeded storage allocation (for current directory or dataset).
553	Requested action not taken. File name not allowed.

600 Series	Replies regarding confidentiality and integrity
631	Integrity protected reply.
632	Confidentiality and integrity protected reply.
633	Confidentiality protected reply.

10000 Series	Common Winsock Error Codes[2] (These are not FTP return codes)
10054	Connection reset by peer. The connection was forcibly closed by the remote host.
10060	Cannot connect to remote server.
10061	Cannot connect to remote server. The connection is actively refused by the server.
10065	No route to host / DNS cannot be resolved.
10066	Directory not empty.
10068	Too many users, server is full.



další na: https://www.serv-u.com/resource/tutorial/appe-stor-stou-retr-list-mlsd-mlst-ftp-command

https://www.nsftools.com/tips/RawFTP.htm